package sng.modules.view.components.city.state
{

	
	import mx.controls.Alert;
	
	import sng.data.info.GlobalInfo;
	import sng.modules.view.components.city.logic.unit.BaseBuilding;
	import sng.utils.AttachmentTextUpUtil;
	
	/**
	 * 
	 * @author kelvinni
	 * 建筑收获状态
	 */	
	public class BuildGatherState extends BuildState
	{
		public function BuildGatherState()
		{
		}
		
		
		public override function execute(build:BaseBuilding):void
		{
			//收取成功后
			//业务逻辑
			build.removeTip();
			
			if(build.currentStrategy.gatherBuildingStrategy())
			{
				//build.setProgress();
				//ui动画
				
				//加入队列操作 edit by royjin 
				build.city.buildingQueueManager.AddBuilding(build);
				
				//减少能量 eason 20110720
				if(GlobalInfo.mainvo.energy>0)
				{
					GlobalInfo.mainvo.energy-=1;
					AttachmentTextUpUtil.addText(build,"-1能量",AttachmentTextUp.WHITE);
				}
				else
				{
					Alert.show("对不起,能量不够！");
					return;
				}

			}
		}
		
		public override function getiStateType():uint
		{
			return 2;
		}
	}
}